﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;

namespace Web_HengliSeed.Sys_Manage
{
    public partial class M_CompanyInfo : System.Web.UI.Page
    {
        protected string NoReBack = "0";
        protected string Order = "0";
        protected string AllProduct = "0";
        protected string AllNews = "0";
        protected void Page_Load(object sender, EventArgs e)
        {
            ClassFile.Function.CheckState();
            if (!IsPostBack)
            {
                LoadData();
            }
        }
        private void LoadData()
        {
            OleDbDataReader DataRead = BLL.CompanyInfo.GetCompanyInfo();
            if (DataRead.HasRows)
            {
                while (DataRead.Read())
                {
                    txtCompanyName.Value = Server.HtmlDecode(DataRead["T_CompanyName"].ToString());
                    txtLink.Value = Server.HtmlDecode(DataRead["T_CompanyTel"].ToString());
                    txtFax.Value = Server.HtmlDecode(DataRead["T_CompanyFax"].ToString());
                    txtMail.Value = Server.HtmlDecode(DataRead["T_CompanyMail"].ToString());
                    txtNo.Value = Server.HtmlDecode(DataRead["T_CompanyNo"].ToString());
                    txtAdress.Value = Server.HtmlDecode(DataRead["T_CompanyAdress"].ToString());
                }
            }
            DataRead.Close();
            DataRead.Dispose();

            string[] strRe = BLL.CompanyInfo.GetSysSPInfo();
            NoReBack = strRe[0];
            Order = strRe[1];
            AllProduct=strRe[2];
            AllNews = strRe[3];
            BLL.SysLog.DelLogInfo();
        }

        protected void BtnSave_Click(object sender, EventArgs e)
        {
            if (txtAdress.Value.Length>120)
            {
                txtAdress.Value=txtAdress.Value.Substring(0,120);
            }
            if (BLL.CompanyInfo.UpdateCompanyInfo(Server.HtmlEncode(txtCompanyName.Value.Trim()), Server.HtmlEncode(txtLink.Value.Trim()), Server.HtmlEncode(txtFax.Value.Trim()), Server.HtmlEncode(txtMail.Value.Trim()), Server.HtmlEncode(txtAdress.Value), Server.HtmlEncode(txtNo.Value.Trim())))
            {
                Common.ShowMessage.Show(Page, "suess", "信息保存成功......");
            }
            else
            {
                Common.ShowMessage.Show(Page, "suess", "信息保存失败，请重试或联系技术人员......");
            }
        }
    }
}
